/**
 * NextHop.java
 *
 * @author Hagen Boehm
 */


package SSF.OS.OSPFv2;


// ======================== class SSF.OS.OSPFv2.NextHop ================================ //
/**
 *  A class containing a router's outgoing interface ip address to use when forwarding 
 *  traffic to a destination and in case of a non point-to-point network the ip address
 *  of the next router in the path towards the destination.
 */
public class NextHop {

  // the ip address of the next router.
  public int nextHopIPAddr;

  // the ip address of the outgoing interface.
  public int viaInterface;

  // ------------------------- constructors NextHop ---------------------------------- //
  
  /**
   *  constructs a NextHop for a point-to-point network.
   *  @param viaIntf IP address of the outgoing interface to use when forwarding packets
   *                 to destination.
   */
  public NextHop(int viaIntf) {
    viaInterface = viaIntf;
    nextHopIPAddr = 0;
  }

  /**
   *  constructs a NextHop for any other network.
   *  @param viaIntf IP address of the outgoing interface to use when forwarding packets
   *                 to destination.
   *  @param nHop IP address of the next hop router.
   */
  public NextHop(int viaIntf, int nHop) {
    viaInterface = viaIntf;
    nextHopIPAddr = nHop;
  }

  // --------------------------- NextHop.equals ------------------------------------- //
  /** Indicates whether a NextHop object is "equal" to this one.
   *  @param nHopObj NextHop object to compare.
   *  @return boolean value indicating true if the Objects are equal else indicating false.
   */
  public boolean equals(Object nHopObj) {
    if (!(nHopObj instanceof NextHop)) return false;
    NextHop nHop = (NextHop)nHopObj;
    if (viaInterface != nHop.viaInterface) {
      return false;
    }
    if (nextHopIPAddr != nHop.nextHopIPAddr) {
      return false;
    }
    return true;
  }

}
